<template>
    <view>
        <uni-list v-if="staffRank.length > 0">
            <uni-list-item v-for="(item, index) in staffRank" :key="index" :rightText="'¥' + numberFormat(item.sfSham, 2)">
                <template v-slot:header>
                    <uni-tag :text="index + 1" :type="getNo(index)" size="normal" />
                </template>
                <template v-slot:body>
                    <view style="flex: 1; margin-left: 10px">{{ item.orName }}</view>
                </template>
                <template v-slot:footer>
                    <view>{{ "¥" + numberFormat(item.sfSham, 2) }}</view>
                </template>
            </uni-list-item>
        </uni-list>

        <u-empty v-if="staffRank.length === 0" text="暂无数据"> </u-empty>
    </view>
</template>

<script>
import { mapGetters } from "vuex";
import { getStaffRanks } from "../../utils/api";
import {getNo} from "../../utils/helper.js"

export default {
    data() {
        return {
            staffRank: [],
        };
    },

    computed: {
        ...mapGetters({
            activity: "activityInfo/activity",
        }),
    },

    onLoad() {
        this.loadStaffRank({ gpUuid: this.activity.gpUuid, orderBy: "SF_SHAM_DESC", first: 20, offset: 0 });
    },

    methods: {
        async loadStaffRank({ gpUuid, orderBy, first = 20, offset = 0 }) {
            let res = await getStaffRanks({ gpUuid, orderBy, first, offset });
            this.staffRank = res?.ranks?.filter((item) => item.sfSham > 10000) || [];
        },
    },
};
</script>

<style lang="scss" scoped></style>
